/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.persistence.test.bean;

import java.util.Date;

import com.genia.toolbox.persistence.bean.Persistable;
import com.genia.toolbox.persistence.criteria.PropertyField;
import com.genia.toolbox.persistence.criteria.SimplePropertyField;

/**
 * An exemple persistent object.
 */
public class PersistentObjectA
    implements Persistable<Long>
{

  /**
   * the name of the variable varString.
   */
  public static final SimplePropertyField<String> NAME_VAR_STRING = PropertyField.create(String.class, "varString");

  /**
   * the name of the variable varInteger.
   */
  public static final SimplePropertyField<Integer> NAME_VAR_INTEGER = PropertyField.create(Integer.class, "varInteger");

  /**
   * the name of the variable varInteger.
   */
  public static final SimplePropertyField<Date> NAME_VAR_DATE = PropertyField.create(Date.class, "varDate");

  /**
   * the name of the variable varPersistentObjectB.
   */
  public static final SimplePropertyField<PersistentObjectB> NAME_VAR_PERSISTENT_OBJECT_B = PropertyField.create(PersistentObjectB.class, "varPersistentObjectB");

  /**
   * the identifier property descriptor.
   */
  public static final SimplePropertyField<Long> NAME_IDENTIFIER = PropertyField.create(Long.class, "identifier");

  /**
   * the identifier of the class.
   */
  private Long identifier;

  /**
   * a variable of type <code>String</code>.
   */
  private String varString;

  /**
   * a variable of type <code>Integer</code>.
   */
  private Integer varInteger;

  /**
   * a variable of type {@link Date}.
   */
  private Date varDate;

  /**
   * a variable of type <code>PersistentObjectB</code>.
   */
  private PersistentObjectB varPersistentObjectB;



  /**
   * Indicates whether some other object is "equal to" this one.
   * 
   * @param obj
   *          the reference object with which to compare.
   * @return <code>true</code> if this object is the same as the obj argument;
   *         <code>false</code> otherwise.
   */
  @Override
  public boolean equals(final Object obj)
  {
    if (obj == null) {
      return false;
    }
    if (obj == this) {
      return true;
    }
    if (identifier == null) {
      return false;
    }
    if (obj instanceof PersistentObjectA) {
      final PersistentObjectA otherA = (PersistentObjectA) obj;
      return identifier.equals(otherA.identifier);
    }
    return false;
  }



  /**
   * getter for the identifier property.
   * 
   * @return the identifier
   */
  public Long getIdentifier()
  {
    return identifier;
  }



  /**
   * getter for the varInteger property.
   * 
   * @return the varInteger
   */
  public Integer getVarInteger()
  {
    return varInteger;
  }



  /**
   * getter for the varPersistentObjectB property.
   * 
   * @return the varPersistentObjectB
   */
  public PersistentObjectB getVarPersistentObjectB()
  {
    return varPersistentObjectB;
  }



  /**
   * getter for the varString property.
   * 
   * @return the varString
   */
  public String getVarString()
  {
    return varString;
  }



  /**
   * Returns a hash code value for the object. This method is supported for the
   * benefit of hashtables such as those provided by
   * <code>java.util.Hashtable</code>.
   * 
   * @return a hash code value for this object.
   */
  @Override
  public int hashCode()
  {
    if (getIdentifier() != null) {
      return getIdentifier().intValue();
    }
    return super.hashCode();
  }



  /**
   * setter for the identifier property.
   * 
   * @param identifier
   *          the identifier to set
   */
  public void setIdentifier(final Long identifier)
  {
    this.identifier = identifier;
  }



  /**
   * setter for the varInteger property.
   * 
   * @param varInteger
   *          the varInteger to set
   */
  public void setVarInteger(final Integer varInteger)
  {
    this.varInteger = varInteger;
  }



  /**
   * setter for the varPersistentObjectB property.
   * 
   * @param varPersistentObjectB
   *          the varPersistentObjectB to set
   */
  public void setVarPersistentObjectB(final PersistentObjectB varPersistentObjectB)
  {
    this.varPersistentObjectB = varPersistentObjectB;
  }



  /**
   * setter for the varString property.
   * 
   * @param varString
   *          the varString to set
   */
  public void setVarString(final String varString)
  {
    this.varString = varString;
  }



  /**
   * getter for the varDate property.
   * 
   * @return the varDate
   */
  public Date getVarDate()
  {
    return varDate;
  }



  /**
   * setter for the varDate property.
   * 
   * @param varDate
   *          the varDate to set
   */
  public void setVarDate(Date varDate)
  {
    this.varDate = varDate;
  }

}
